home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / util / cdity / ModeProSrc.lha / Prefs / MPP3dLV.c < prev    next >
C/C++ Source or Header  |  2000-09-17  |  3KB  |  116 lines

  1. #include "mpp.h"
  2. #include <graphics/rpattr.h>
  3. #include <extras/ext_text.h>
  4.  
  5.  
  6. LONG   PenListOffset;
  7. extern UBYTE  PenNames[DRIPENS][32];
  8. extern WORD   PenNameLength[DRIPENS];
  9. extern UWORD  NumDriPens;
  10. extern LONG ActivePen;
  11.  
  12. void FindMaxPenNameSize(struct TextAttr *TA)
  13. {
  14.   struct TextFont *font;
  15.   LONG clen,dashlen;
  16.   char c[2];
  17.   
  18.   c[1]=0;
  19.   PenListOffset=0;
  20.  
  21.   if(font=OpenDiskFont(TA))
  22.   {
  23.     c[0]='-';
  24.  
  25.     dashlen=gui_StrFontLen(font,c);//                                                                  (4.64.6) (09/17/00)
  26.   
  27.     for(c[0]='0';c[0]<='9';c[0]++)
  28.     {
  29.       clen=gui_StrFontLen(font,c);//                                                                   (4.64.5) (09/17/00)
  30.       PenListOffset=max(PenListOffset,clen);
  31.     }
  32.     
  33.     PenListOffset=PenListOffset*5 + dashlen;
  34.     CloseFont(font);
  35.   }
  36. }
  37.  
  38. ULONG __saveds __asm PensLVFunc(register __a0 struct Hook *Hook,
  39.                                 register __a1 struct LVDrawMsg *Dm,
  40.                                 register __a2 struct PenNode *PN)
  41.   struct RastPort *rp;
  42.   LONG top,bottom,left,right,baseline;
  43.   LONG fgpen,bgpen;
  44.   LONG pen,penlen,offset;
  45.   ULONG state;
  46.   
  47.   if(Dm->lvdm_MethodID!=LV_DRAW)
  48.     return(LVCB_UNKNOWN);
  49.  
  50.   left  =Dm->lvdm_Bounds.MinX;
  51.   top   =Dm->lvdm_Bounds.MinY;
  52.   right =Dm->lvdm_Bounds.MaxX;
  53.   bottom=Dm->lvdm_Bounds.MaxY;
  54.  
  55.   rp=Dm->lvdm_RastPort;
  56.   
  57.   state=Dm->lvdm_State;
  58.  
  59.   if(LVR_SELECTED == state || LVR_SELECTEDDISABLED == state || ActivePen == PN->PenNumber)
  60.   {
  61.     fgpen=Dm->lvdm_DrawInfo->dri_Pens[FILLTEXTPEN];
  62.     bgpen=Dm->lvdm_DrawInfo->dri_Pens[FILLPEN];
  63.   }
  64.   else
  65. /*    if (  )
  66.     {
  67.       fgpen=Dm->lvdm_DrawInfo->dri_Pens[TEXTPEN];
  68.       bgpen=Dm->lvdm_DrawInfo->dri_Pens[FILLPEN];
  69.     }
  70.     else*/
  71.   {
  72.     fgpen=Dm->lvdm_DrawInfo->dri_Pens[TEXTPEN];
  73.     bgpen=Dm->lvdm_DrawInfo->dri_Pens[BACKGROUNDPEN];
  74.   }
  75.  
  76.   SetAPen(rp,bgpen);
  77.  
  78.   RectFill(rp,left,top,right,bottom);
  79.  
  80.   baseline=rp->Font->tf_Baseline+top;
  81.  
  82.   SetRPAttrs(rp,
  83.              RPTAG_APen   ,fgpen,
  84.              RPTAG_DrMd   ,JAM1,
  85.              TAG_DONE);
  86.  
  87.   pen=PN->PenNumber;
  88.   penlen=PenNameLength[pen];
  89.   
  90. //  offset=right-2-PenListOffset-TextLength(rp,PenNames[pen],penlen);
  91.  
  92.   offset=right-2-PenListOffset;
  93.   
  94.   gui_RenderText(rp,PenNames[pen],
  95.              RT_XPos          ,offset,
  96.              RT_Baseline      ,baseline,
  97.              RT_MaxWidth      ,offset-left,
  98.              RT_Strlen        ,penlen,
  99.              RT_Justification ,RTJ_RIGHT,
  100.              TAG_DONE); 
  101.   gui_RenderText(rp,&PenNames[pen][penlen],
  102.              RT_XPos          ,offset,
  103.              TAG_DONE);
  104.  
  105. /*
  106.   Move(rp,offset,baseline);
  107.   Text(rp,PenNames[pen],strlen(PenNames[pen]));
  108. */
  109.  
  110.   if(LVR_NORMALDISABLED == state || LVR_SELECTEDDISABLED == state )
  111.     gui_GhostRect(rp,Dm->lvdm_DrawInfo->dri_Pens[TEXTPEN],left,top,right,bottom);//                        (4.64.7) (09/17/00)
  112.   
  113.   return(LVCB_OK);
  114. }
  115.